package com.huluobo.a2202mvvm_im_douyindemo.cart;

import androidx.lifecycle.MutableLiveData;

import com.huluobo.a2202mvvm_im_douyindemo.bean.CartBeanResult;
import com.huluobo.a2202mvvm_im_douyindemo.mvvmBase.BaseRepo;

import io.reactivex.Observer;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.Disposable;
import io.reactivex.schedulers.Schedulers;

/**
 * Created by LC on 2024/5/15.
 */
public class CartRepo extends BaseRepo {
    public void queryCartList(MutableLiveData<CartBeanResult> success, MutableLiveData<String> failed) {
        apiService.queryCartList()
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Observer<CartBeanResult>() {
                    @Override
                    public void onSubscribe(Disposable d) {

                    }

                    @Override
                    public void onNext(CartBeanResult cartBeanResult) {
                        success.setValue(cartBeanResult);
                    }

                    @Override
                    public void onError(Throwable e) {
                        failed.setValue(e.getMessage());
                    }

                    @Override
                    public void onComplete() {

                    }
                });
    }
}
